home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
newsgroups
/
misc.20031118-20041115
/
000367_fdc@columbia.edu_Fri Aug 20 09:26:14 2004.msg
< prev
next >
Wrap
Internet Message Format
|
2020-01-01
|
2KB
Path: newsmaster.cc.columbia.edu!not-for-mail
From: Frank da Cruz <fdc@columbia.edu>
Newsgroups: comp.protocols.kermit.misc
Subject: Re: discovering remote directories via ftp
Date: 20 Aug 2004 13:25:37 GMT
Organization: Columbia University
Lines: 44
Message-ID: <slrncibuuh.ams.fdc@sesame.cc.columbia.edu>
References: <c00b47e5.0408191310.6d364c08@posting.google.com>
Reply-To: fdc@columbia.edu
NNTP-Posting-Host: sesame.cc.columbia.edu
X-Trace: newsmaster.cc.columbia.edu 1093008337 25022 128.59.59.56 (20 Aug 2004 13:25:37 GMT)
X-Complaints-To: postmaster@columbia.edu
NNTP-Posting-Date: 20 Aug 2004 13:25:37 GMT
User-Agent: slrn/0.9.8.0 (SunOS)
Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:15129
On 2004-08-19, Logan <lcolby@magnaspeed.net> wrote:
: The ftpdirectory script
: (ftp://kermit.columbia.edu/kermit/scripts/ckermit/ftpdirectory) shows
: how to get a file listing from a remote server. Is it possible to
: extend this to directory listings? I'd like to be able to script the
: retrieval of a file from the most recent directory d.x from [d.1, d.2,
: ... d.z]. At the very least, can I redirect the results of a remote
: dir either to a local variable or to a local file?
:
If the server includes directories in its NLST reply. Some do, some
don't. Or if the server supports MLSD:
http://www.columbia.edu/kermit/newftp.html
Assuming the server's NLST reply includes directories, you can modify
the ftpdirectory script to test for this by trying to CD to each file.
If it succeeds, it's a directory (and you have to remember to CDUP to
get back where you were); if it fails, it's (probably) an ordinary file.
undef dir
ftp cd \m(name)
if success {
ftp cdup
.dir := "(DIRECTORY)"
}
echo "\flpad(\m(size),12) \fcvtdate(\m(time)) \m(name) \m(dir)" ; Show info
Unfortunately, most FTP servers do NOT return directory names in their
NLST replies, nor do they support MLSD. This is one of many reasons we
created IKSD:
http://www.columbia.edu/kermit/iksd.html
It gets around FTP limitations such as this one, and many others too.
If the FTP server does not report directories and you can't install IKSD on
the server, your only other alternative is to use LIST, save the result to
a file:
ftp directory * > localfilename
and "parse" the file.
- Frank